package _111MinMumDepthOfBinaryTree;

public class CSolution {

  public static void main(String[] args) {
    System.out.println("aa");
    CSolution cSolution = new CSolution();
    TreeNode t1 = new TreeNode(1);
    TreeNode t2 = new TreeNode(2);
    t1.right = t2;
    int de = cSolution.minDepth(t1);
    cSolution.minDepth(t1);
  }

  private int minDepth(TreeNode root) {
    int depth = 0;
    return process(root,depth);
  }

  private int process(TreeNode t1, int depth) {
    if (t1 == null) {
      return depth;
    }
    if (t1.left == null && t1.right == null) {
      return depth + 1;
    }
    if (t1.left != null && t1.right != null) {
      return Math.min(process(t1.left, depth + 1), process(t1.right, depth + 1));
    } else if (t1.left != null) {
      return process(t1.left, depth + 1);
    } else {
      return process(t1.right, depth + 1);
    }
  }
}
